Conversation
…ser_agent_overwrite
Member
Author
|
/azp run python - cosmos - tests |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a regression in azure-cosmos (introduced in v4.15.0b1) where user_agent_overwrite was unintentionally left in the kwargs passed down into the transport layer, causing requests.Session.request() to raise a TypeError.
Changes:
- Pop
user_agent_overwritefrom client-connectionkwargsin both sync and async Cosmos client connection implementations to prevent it from leaking into lower layers. - Add sync + async regression tests that exercise combinations of
user_agent,user_agent_suffix, anduser_agent_overwriteto ensure no transport-level kwarg leakage.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sdk/cosmos/azure-cosmos/azure/cosmos/_cosmos_client_connection.py | Removes user_agent_overwrite from kwargs after it has been consumed for policy setup (sync path). |
| sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client_connection_async.py | Removes user_agent_overwrite from kwargs after it has been consumed for policy setup (async path). |
| sdk/cosmos/azure-cosmos/tests/test_user_agent.py | Adds a sync regression test to validate user_agent_overwrite doesn’t leak into transport kwargs. |
| sdk/cosmos/azure-cosmos/tests/test_user_agent_async.py | Adds an async regression test to validate user_agent_overwrite doesn’t leak into transport kwargs. |
simorenoh
approved these changes
Mar 12, 2026
sdk/cosmos/azure-cosmos/azure/cosmos/aio/_cosmos_client_connection_async.py
Show resolved
Hide resolved
simorenoh
approved these changes
Mar 12, 2026
rohitsinghal4u
pushed a commit
that referenced
this pull request
Mar 16, 2026
… argument 'user_agent_overwrite' (#45653) * fix - TypeError: Session.request() got an unexpected word argument 'user_agent_overwrite * fix - updating changelog --------- Co-authored-by: Simon Moreno <30335873+simorenoh@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes a regression introduced with v4.15.0b1 release where the user_agent_overwrite kwarg was not popped from kwargs after being consumed by CosmosUserAgentPolicy.init(). This caused the kwarg to leak through _GetDatabaseAccount(**kwargs) into the HTTP transport layer, resulting in:
TypeError: requests.Session.request() got an unexpected keyword argument 'user_agent_overwrite'